package com.dms.modules.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dms.modules.order.entity.OrderItem;
import com.dms.modules.order.mapper.OrderItemMapper;
import com.dms.modules.order.service.OrderItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class OrderItemServiceImpl extends ServiceImpl<OrderItemMapper, OrderItem> implements OrderItemService {

    @Override
    public List<OrderItem> getOrderItems(Long orderId) {
        try {
            log.info("Getting order items for order: {}", orderId);
            LambdaQueryWrapper<OrderItem> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(OrderItem::getOrderId, orderId);
            return list(queryWrapper);
        } catch (Exception e) {
            log.error("Failed to get order items for order: {}", orderId, e);
            return new ArrayList<>();
        }
    }
} 